package com.example.demo.controller;

import com.example.demo.bean.Node;
import com.example.demo.common.PageResult;
import com.example.demo.common.Result;
import com.example.demo.jwt.ResultCode;
import com.example.demo.service.NodeService;
import com.example.demo.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/api/node")
public class NodeController {

    private static final Logger log = LoggerFactory.getLogger(NodeController.class);

    private final NodeService s;

    @Autowired
    public NodeController(NodeService s) {
        this.s = s;
    }

    @GetMapping("/nodeInfoByTitle")
    public Result<Node> getNodeInfoByTitle(@RequestParam String title){
        log.info("获取当前节点信息接口被调用");
        try{
            Node n = s.getNodeByTitle(title);
            return Result.success(n);
        } catch (Exception e) {
            return Result.error(ResultCode.ERROR.getCode(),"获取节点信息失败"+e.getMessage());
        }
    }

}